﻿namespace Vdc.Grid
{
    using Vdc.Grid.Design;
    using System;
    using System.ComponentModel;

    [TypeConverter(typeof(GridExportingSettingsConverter))]
    public class GridExportingSettings : GridPersistentObject, ICloneable
    {
        public object Clone()
        {
            return new GridExportingSettings { AppendTimeStamp = this.AppendTimeStamp, ColumnsToExport = this.ColumnsToExport, Encoding = this.Encoding, ExportAllPages = this.ExportAllPages, ExportColumnsFooter = this.ExportColumnsFooter, ExportDetails = this.ExportDetails, ExportedFilesLifeTime = this.ExportedFilesLifeTime, ExportedFilesTargetWindow = this.ExportedFilesTargetWindow, ExportGroupFooter = this.ExportGroupFooter, ExportGroupHeader = this.ExportGroupHeader, ExportHiddenColumns = this.ExportHiddenColumns, ExportTemplates = this.ExportTemplates, FileName = this.FileName };
        }

        public virtual bool Equals(GridExportingSettings settings)
        {
            return (((((this.AppendTimeStamp == settings.AppendTimeStamp) && !(this.ColumnsToExport != settings.ColumnsToExport)) && ((this.Encoding == settings.Encoding) && (this.ExportAllPages == settings.ExportAllPages))) && (((this.ExportColumnsFooter == settings.ExportColumnsFooter) && (this.ExportDetails == settings.ExportDetails)) && ((this.ExportedFilesLifeTime == settings.ExportedFilesLifeTime) && (this.ExportedFilesTargetWindow == settings.ExportedFilesTargetWindow)))) && (((this.ExportGroupFooter == settings.ExportGroupFooter) && (this.ExportGroupHeader == settings.ExportGroupHeader)) && (((this.ExportHiddenColumns == settings.ExportHiddenColumns) && (this.ExportTemplates == settings.ExportTemplates)) && !(this.FileName != settings.FileName))));
        }

        object ICloneable.Clone()
        {
            return this.Clone();
        }

        [NotifyParentProperty(true), Description("Gets or sets a value indicating whether a timestamp should be appended to the name of the exported file."), Bindable(true), Category("Exporting"), DefaultValue(true)]
        public bool AppendTimeStamp
        {
            get
            {
                object obj2 = base.ViewState["AppendTimeStamp"];
                if (obj2 != null)
                {
                    return (bool) obj2;
                }
                return true;
            }
            set
            {
                base.ViewState["AppendTimeStamp"] = value;
            }
        }

        [Description("Gets or sets a value indicating which columns will be exported."), Bindable(true), Category("Exporting"), DefaultValue(""), NotifyParentProperty(true)]
        public string ColumnsToExport
        {
            get
            {
                object obj2 = base.ViewState["ColumnsToExport"];
                if (obj2 != null)
                {
                    return obj2.ToString();
                }
                return "";
            }
            set
            {
                base.ViewState["ColumnsToExport"] = value;
            }
        }

        [Bindable(true), DefaultValue(2), Description("Gets or sets a value indicating the encoding type that will be used for exporting."), Category("Exporting"), NotifyParentProperty(true)]
        public GridExportEncoding Encoding
        {
            get
            {
                object obj2 = base.ViewState["Encoding"];
                if (obj2 != null)
                {
                    return (GridExportEncoding) obj2;
                }
                return GridExportEncoding.Default;
            }
            set
            {
                base.ViewState["Encoding"] = value;
            }
        }

        [Category("Exporting"), Bindable(true), Description("Gets or sets a value indicating whether all the pages from the Grid will be exported."), DefaultValue(false), NotifyParentProperty(true)]
        public bool ExportAllPages
        {
            get
            {
                object obj2 = base.ViewState["ExportAllPages"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                base.ViewState["ExportAllPages"] = value;
            }
        }

        [Bindable(true), Description("Gets or sets a value indicating whether the columns footer row will be exported."), Category("Exporting"), DefaultValue(false), NotifyParentProperty(true)]
        public bool ExportColumnsFooter
        {
            get
            {
                object obj2 = base.ViewState["ExportColumnsFooter"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                base.ViewState["ExportColumnsFooter"] = value;
            }
        }

        [NotifyParentProperty(true), Bindable(true), Category("Exporting"), DefaultValue(false), Description("Gets or sets a value indicating whether the detail grids will be exported.")]
        public bool ExportDetails
        {
            get
            {
                object obj2 = base.ViewState["ExportDetails"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                base.ViewState["ExportDetails"] = value;
            }
        }

        [Category("Exporting"), Bindable(true), DefaultValue(0), Description("Sets the life time for the exported files.")]
        public int ExportedFilesLifeTime
        {
            get
            {
                object obj2 = this.ViewState["ExportedFilesLifeTime"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 0;
            }
            set
            {
                this.ViewState["ExportedFilesLifeTime"] = value;
            }
        }

        [Bindable(true), Category("Exporting"), DefaultValue(0), Description("The browser window where the exported file should be opened.")]
        public ExportedFilesTargetWindowType ExportedFilesTargetWindow
        {
            get
            {
                object obj2 = this.ViewState["ExportedFilesTargetWindow"];
                if (obj2 != null)
                {
                    return (ExportedFilesTargetWindowType) obj2;
                }
                return ExportedFilesTargetWindowType.Current;
            }
            set
            {
                base.ViewState["ExportedFilesTargetWindow"] = value;
            }
        }

        [Description("Gets or sets a value indicating whether the group footer rows will be exported."), Bindable(true), Category("Exporting"), DefaultValue(false), NotifyParentProperty(true)]
        public bool ExportGroupFooter
        {
            get
            {
                object obj2 = base.ViewState["ExportGroupFooter"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                base.ViewState["ExportGroupFooter"] = value;
            }
        }

        [Bindable(true), NotifyParentProperty(true), Description("Gets or sets a value indicating whether the group header rows will be exported."), DefaultValue(false), Category("Exporting")]
        public bool ExportGroupHeader
        {
            get
            {
                object obj2 = base.ViewState["ExportGroupHeader"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                base.ViewState["ExportGroupHeader"] = value;
            }
        }

        [Bindable(true), DefaultValue(false), Description("Gets or sets a value indicating whether the hidden columns will be exported."), NotifyParentProperty(true), Category("Exporting")]
        public bool ExportHiddenColumns
        {
            get
            {
                object obj2 = base.ViewState["ExportHiddenColumns"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                base.ViewState["ExportHiddenColumns"] = value;
            }
        }

        [DefaultValue(false), NotifyParentProperty(true), Description("Gets or sets a value indicating whether the templates will be exported."), Category("Exporting"), Bindable(true)]
        public bool ExportTemplates
        {
            get
            {
                object obj2 = base.ViewState["ExportTemplates"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                base.ViewState["ExportTemplates"] = value;
            }
        }

        [Description("Gets or sets a value indicating the name of the exported file."), NotifyParentProperty(true), Bindable(true), Category("Exporting"), DefaultValue("Grid")]
        public string FileName
        {
            get
            {
                object obj2 = base.ViewState["FileName"];
                if (obj2 != null)
                {
                    return obj2.ToString();
                }
                return "Grid";
            }
            set
            {
                base.ViewState["FileName"] = value;
            }
        }

        [Bindable(true), DefaultValue(false), NotifyParentProperty(true), Description("Gets or sets a value indicating whether the settings of the columns will be kept when exporting."), Category("Exporting")]
        public bool KeepColumnSettings
        {
            get
            {
                object obj2 = base.ViewState["KeepColumnSettings"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                base.ViewState["KeepColumnSettings"] = value;
            }
        }
    }
}

